home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1451 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: JamesCurran@CIS.CompuServe.Com (James M. Curran)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do you pass along a variable argument list?
  5. Date: Sun, 14 Jan 1996 02:02:16 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4d9o7c$glb@dub-news-svc-6.compuserve.com>
  8. References: <4d1i8v$k8h@news.mcl.bdm.com> <4d30nv$k8r@tahko.lpr.carel.fi> <ALUN.CHAMPION.96Jan11093732@g7240065.bridge.bst.bls.com>
  9. NNTP-Posting-Host: dd01-001.compuserve.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. >>: ywu@plato.sky.bdm.com wrote:
  13. >>:> I am writing a wrapper around a routine which takes variable argument list only. I  
  14. >>:> want my wrapper has the similar prototype and can pass the variable arguments  
  15. >>:> directly to the routine(by the way, I cannot change the code of that routine).
  16. >>:> I guess it is really hard to do it in ANSI, and I know how to do it in a stupid  
  17. >>:> way---but, is there any way around??
  18.  
  19.  
  20.     Actually, I think most of the posters here are missing the point of the
  21. originally message.  As I read it, he has a function defined as such:
  22.  
  23.     int other_func(int X,...);
  24.  
  25.  which *cannot* be changed, and he wants to write a function similar to:
  26.  
  27.     int my_func(int X,....)
  28.     {
  29.         /* work with X here */
  30.         /* then --- */
  31.         other_func(/* OK, so what exactly do we put here ?*/);
  32.     }
  33.  
  34.  
  35.   which as far as I can see means he's pretty much screwed.   The only think
  36. I can think of have him try is:
  37.  
  38.     int my_func(int X,....)
  39.  
  40.  
  41.     int my_func(int A, int B, int C, int D, int E, int F, int G /* etc */ .)
  42.     {
  43.         /* work with A here */
  44.         /* then --- */
  45.         other_func(A,B,C, D, E, F, G /*etc */);
  46.     }
  47.     
  48.   adding enough variables to the list to cover every foreseeable case.  The
  49. only thing I can say about this method, is that it'll probably work in most
  50. cases...
  51.  
  52.  
  53.  
  54.